package com.qcby.service.impl;

import com.qcby.dao.AdminDao;
import com.qcby.entity.Admin;
import com.qcby.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminDao adminDao;

    @Override
    public List<Admin> SelectAdmin(Admin admin, HttpServletRequest request) {
        List<Admin> admins = adminDao.SelectAdmin(admin);
        if (admins.size()>0){
            HttpSession session = request.getSession();
            session.setAttribute("admin",admins.get(0));
            return admins;
        }else{
            return null;
        }

    }
}
